package com.demo.project_template.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.project_template.entity.Feedback;
import com.demo.project_template.entity.Post;
import com.demo.project_template.service.FeedbackService;
import com.demo.project_template.service.PostService;
import com.demo.project_template.vo.response.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 杨玉龙
 * @since 2024-08-21 11:53:54
 */
@Api(tags = "用户反馈")
@RestController
@RequestMapping("/feedback")
public class FeedbackController {

    @Resource
    private FeedbackService feedbackService;

    @ApiOperation(value = "分页查询反馈")
    @GetMapping(value = "/page")
    public R<IPage<Feedback>> page(@RequestParam Integer pageNo,
                                   @RequestParam Integer pageSize) {
        Page<Feedback> result = feedbackService.page(new Page<>(pageNo, pageSize));
        return R.success(result);
    }

    @ApiOperation(value = "添加反馈")
    @PostMapping(value = "/add")
    public R<?> add(@RequestBody Feedback feedback) {
        feedbackService.save(feedback);
        return R.success();
    }

    @ApiOperation(value = "删除反馈")
    @DeleteMapping(value = "/id")
    public R<?> delete(@RequestParam Long id) {
        feedbackService.removeById(id);
        return R.success();
    }
}
